define(
	[
	appBasePath + '/scripts/module.js',
	],
	function (substanceModule) {

    'use strict';

    substanceModule.controller('Demo.EditController', [
        '$scope',
        '$state',
        '$stateParams',
        'gbits.websns.substance.config',     
        'Demo.TodoService',
        function($scope, $state, $stateParams, config, todoService) {
        	$scope.basePath = config.basePath;         	
        	$scope.model = {
    			id:$stateParams.id,
        		content :''
        	};
        	
        	$scope.save = function() {        		
        		todoService.save($scope.model).then(function(data) { 
        			if (data) {        			
        				$state.go('kernel.appList.substance.list');
        			}
        		});
        	}
        	
        	function loadData() {        		
        		todoService.getTodoItemById($scope.model.id).then(function(data) {
        			if (data) {
        				$scope.model.content = data.content;        			
        			}
        		});
        	}
        	
        	loadData();
        }
    ]);
});